package com.iversonx.decorator.example_1.service.v2.calculator;

import com.iversonx.decorator.example_1.service.v2.PrizeCalculator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigDecimal;

public class SumPrizeCalculator implements PrizeCalculator {
    private final Logger logger = LoggerFactory.getLogger(SumPrizeCalculator.class);
    private final BigDecimal NUM_1000_000 = new BigDecimal("1000000");

    private final PrizeCalculator prizeCalculator;
    public SumPrizeCalculator(PrizeCalculator prizeCalculator) {
        this.prizeCalculator = prizeCalculator;
    }
    @Override
    public BigDecimal calc(String user) {
        BigDecimal prize = prizeCalculator.calc(user);

        BigDecimal sumPrize = NUM_1000_000.multiply(new BigDecimal("0.001"));
        logger.info("{}累计奖金:{}", user, sumPrize);
        return prize.add(sumPrize);

    }
}
